package datastructure_algorithm.bst;

public class _Test {

	public static void main(String[] args) {
		BST<Integer> bst = new BST<>();
		int[] nums = { 5, 3, 6, 8, 4, 2 };
//		int[] nums = { 5 }; 
		for (int n : nums) {
			bst.add(n);
		}

		//////////////////
		//       5      //
		//     /   \    //
		//    3     6   //
		//   / \     \  //
		//  2   4     8 //
		//////////////////
		System.out.println(bst);
		
		System.out.println("Contains 6: " + bst.contains(6));

		// 各种遍历方式
		System.out.println("前序遍历---");
		bst.preOrder(); // 5 3 2 4 6 8
		System.out.println("非递归前序遍历---");
		bst.preOrderNR(); // 5 3 2 4 6 8
		System.out.println("中序遍历---");
		bst.inOrder(); // 2 3 4 5 6 8
		System.out.println("后序遍历---");
		bst.postOrder(); // 2 4 3 8 6 5
		System.out.println("层级遍历---");
//		bst.levelOrder();

		System.out.println();
		System.out.println("bst minimum: " + bst.minimum());
		System.out.println("bst maximum: " + bst.maximum());

		Integer removeMin = bst.removeMin();
		System.out.println("remove min:" + removeMin);
		Integer removeMax = bst.removeMax();
		System.out.println("remove max:" + removeMax);
		System.out.println(bst);
	}

}
